package com.boot.start.config.exception;

import com.boot.start.config.result.ResultResponse;
import com.boot.start.config.result.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 墨龙吟
 * @version 1.0.0
 * @ClassName ExceptionConfig.java
 * @Email 2354713722@qq.com
 * @Description 异常配置类
 * @createTime 2020年05月18日 - 23:09
 */
@Slf4j
@RestControllerAdvice
public class ExceptionConfig {


    @ResponseBody
    @ExceptionHandler(Exception.class)
    public ResultResponse systemExceptionHandler(HttpServletRequest request, Exception e) {
        log.info("捕获异常..." + e.getMessage());
        return ResultResponse.fail.build(StatusCode.FAIL);
    }

}
